package com.atguigu.staservice.schedule;

import com.atguigu.staservice.service.StatisticsDailyService;
import com.atguigu.staservice.utils.DateUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Author zhaolie
 * @Date 2021/1/4 3:54 下午
 * @Version 1.0
 * @Description
 */

@Component
public class ScheduledTask {


    @Resource
    private StatisticsDailyService dailyService;

    @Scheduled(cron = "0 0 1 * * ?")
    public void task1() {
        String date = DateUtil.formatDate(DateUtil.addDays(new Date(), -1));
        dailyService.registerCount(date);
    }
}
